
#ifndef __KHAN_PTY_SHELL_HPP__
#define __KHAN_PTY_SHELL_HPP__

#include "khan.hpp"

class pty_shell
: public boost::enable_shared_from_this<pty_shell>,                               
private boost::noncopyable       
{
public:
    pty_shell():
        _ptyfd(0),
        _shell_pid(0)
    {};

    void set_pid(pid_t);
    pid_t get_pid() { return _shell_pid; };
    int get_ptyfd() { return _ptyfd; };
    int open_pty(const string_vector& cmdvec);
    void close_pty();

private:
    int _ptyfd;
    pid_t   _shell_pid;
};

typedef boost::shared_ptr<pty_shell> pty_shell_ptr;
typedef std::map<pid_t, pty_shell_ptr> pty_map;

class pty_manager /* FIXME: thread-safty */
{
public:

    static void add(pid_t, pty_shell_ptr);
    static void remove(pid_t);

private:
    explicit pty_manager(){};
    static pty_map     _map;
};

#endif /* __KHAN_PTY_SHELL_HPP__ */
